package core.network.client2game.handler.tdk;

import java.io.IOException;
import java.util.Objects;

import business.global.pk.tdk.TDKRoom;
import business.tdk.c2s.iclass.CTDK_Kan;
import com.ddm.server.websocket.def.ErrorCode;
import com.ddm.server.websocket.handler.requset.WebSocketRequest;
import com.google.gson.Gson;
import business.global.room.RoomMgr;
import business.player.Player;
import core.network.client2game.handler.PlayerHandler;

/**
 * 看牌
 * @author Huaxing
 *
 */
public class CTDKKan extends PlayerHandler {
	

    @SuppressWarnings("rawtypes")
	@Override
    public void handle(Player player, WebSocketRequest request, String message) throws IOException {
    	final CTDK_Kan req = new Gson().fromJson(message, CTDK_Kan.class);
    	long roomID = req.roomID;    	
    	TDKRoom room = (TDKRoom) RoomMgr.getInstance().getRoom(roomID);
    	if (Objects.isNull(room)){
    		request.error(ErrorCode.NotAllow, "CTDKKan not find room:"+roomID);
    		return;
    	}
    	room.opKan(request,player.getPid(), req.pos);
    }
}
